<template>
  <a-card class="stat-card" :hoverable="true">
    <div class="stat-content">
      <div class="stat-icon" :style="{ backgroundColor: iconBgColor }">
        <component :is="icon" :style="{ color: '#fff', fontSize: '24px' }" />
      </div>
      <div class="stat-info">
        <div class="stat-value">{{ value }}</div>
        <div class="stat-label">{{ label }}</div>
        <div class="stat-trend" :class="{ 'trend-up': trend > 0, 'trend-down': trend < 0 }">
          <span class="trend-icon">
            <CaretUpOutlined v-if="trend > 0" />
            <CaretDownOutlined v-else-if="trend < 0" />
          </span>
          <span class="trend-value">{{ Math.abs(trend) }}%</span>
        </div>
      </div>
    </div>
  </a-card>
</template>

<script setup>
import { CaretUpOutlined, CaretDownOutlined } from '@ant-design/icons-vue'

const props = defineProps({
  value: {
    type: [String, Number],
    required: true
  },
  label: {
    type: String,
    required: true
  },
  trend: {
    type: Number,
    default: 0
  },
  icon: {
    type: [Object, Function],
    required: true
  },
  iconBgColor: {
    type: String,
    default: '#1890ff'
  }
})
</script>

<style scoped>
.stat-card {
  border-radius: 12px;
  border: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.09);
  transition: all 0.3s ease;
}

.stat-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.stat-content {
  display: flex;
  align-items: center;
  gap: 16px;
}

.stat-icon {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-info {
  flex: 1;
  min-width: 0;
}

.stat-value {
  font-size: 24px;
  font-weight: 600;
  color: #262626;
  margin-bottom: 4px;
  line-height: 1;
}

.stat-label {
  font-size: 14px;
  color: #8c8c8c;
  margin-bottom: 8px;
}

.stat-trend {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 500;
}

.trend-up {
  color: #52c41a;
}

.trend-down {
  color: #f5222d;
}

.trend-icon {
  display: flex;
  align-items: center;
}

@media (max-width: 768px) {
  .stat-content {
    gap: 12px;
  }
  
  .stat-icon {
    width: 48px;
    height: 48px;
  }
  
  .stat-value {
    font-size: 20px;
  }
}
</style>